package States;

import java.util.ArrayList;

import Operators.CMOperators.InitialState;
import Templates.State;

public class CMState {
	private int LeftCanibals;
	private int RightCanibals;
	private int LeftMissionaries;
	private int RightMissionaries;
	private String boat="right";
	
	public static State<CMState> initalState()
	{
		return new State<CMState>(new CMState(0,0,3,3,"right"),new InitialState() );
	}
	
	public static ArrayList<State<CMState>> finalStates()
	{
		ArrayList<State<CMState>> fStates=new ArrayList<State<CMState>>();
		fStates.add(new State<CMState>(new CMState(3,3,0,0,"left"),null));
		return fStates;
	}
	
	public CMState(CMState s)
	{
		LeftCanibals = s.LeftCanibals;
		RightCanibals = s.RightCanibals;
		LeftMissionaries = s.LeftMissionaries;
		RightMissionaries = s.RightMissionaries;
		boat = s.boat;
	}
	
	public String getBoat() {
		return boat;
	}

	public void setBoat(String boat) {
		this.boat = boat;
	}

	public CMState(int leftCanibals, int leftMissionaries, int rightCanibals,
			int rightMissionaries,String boat) {
		LeftCanibals = leftCanibals;
		RightCanibals = rightCanibals;
		LeftMissionaries = leftMissionaries;
		RightMissionaries = rightMissionaries;
		this.boat=boat;
	}
	public int getLeftCanibals() {
		return LeftCanibals;
	}
	public void setLeftCanibals(int leftCanibals) {
		LeftCanibals = leftCanibals;
	}
	public int getRightCanibals() {
		return RightCanibals;
	}
	public void setRightCanibals(int rightCanibals) {
		RightCanibals = rightCanibals;
	}
	public int getLeftMissionaries() {
		return LeftMissionaries;
	}
	public void setLeftMissionaries(int leftMissionaries) {
		LeftMissionaries = leftMissionaries;
	}
	public int getRightMissionaries() {
		return RightMissionaries;
	}
	public void setRightMissionaries(int rightMissionaries) {
		RightMissionaries = rightMissionaries;
	}

	public String toString()
	{
		String LeftString=new String("Left Side: Canibals: ");
		String RightString=new String("Right Side: Canibals: ");
		LeftString+=this.getLeftCanibals();
		LeftString+=" Missionaries: ";
		LeftString+=this.getLeftMissionaries();
		RightString+=this.getRightCanibals();
		RightString+=" Missionaries: ";
		RightString+=this.getRightMissionaries();

		return LeftString + " ~ " + RightString + " boat is "+this.getBoat();
	}
}
